using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using FinlogiK.FxCop.Statistics.Windows.Properties;


namespace FinlogiK.FxCop.Statistics.Windows
{
	internal sealed partial class DatabaseConfigurationForm : Form
	{
		#region Constructors

		internal DatabaseConfigurationForm()
		{
			InitializeComponent();
		}

		#endregion

		#region Methods

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			this.connectionStringTextBox.Text = Settings.Default.StatisticsDatabase;
		}

		private void buildConnectionStringButton_Click(object sender, EventArgs e)
		{
			using (ConnectionStringDialog dialog = new ConnectionStringDialog())
			{
				dialog.ConnectionString = this.connectionStringTextBox.Text;
				if (dialog.ShowDialog(this) == DialogResult.OK) this.connectionStringTextBox.Text = dialog.ConnectionString;
			}
		}

		private void okButton_Click(object sender, EventArgs e)
		{
			Settings userSettings = Settings.Default;
			userSettings.StatisticsDatabase = this.connectionStringTextBox.Text.Trim();
			userSettings.Save();

			this.Close();
		}

		private void cancelButton_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		#endregion
	}
}